import { CopyInfoPanelBase } from "../../copy/CopyInfoPanelBase";
import { ImagesConst } from "../../../resource/ImagesConst";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { TaskTargetInfo } from "../../../model/TaskTargetInfo";
import { MapIdRule } from "../../../rules/MapIdRule";
import { EntityType } from "../../../rules/EntityType";
import { FlyFootBmp } from "../../mapUI/flyFoot/FlyFootBmp";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { LRAwardItemRenderer } from "./LRAwardItemRenderer";
import { SecTimerView } from "../../common/SecTimerView";
import { FilterConst } from "../../../../component/gconst/FilterConst";
import { AIManager } from "../../../scene/ai/AIManager";
import { AIType } from "../../../scene/ai/AIType";
import { LRAwardItemVo } from "./info/LRAwardItemVo";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
type int = number;
//class LanternRiddlesPanel
    
    export  class LanternRiddlesPanel extends CopyInfoPanelBase
    {
        constructor()
        {
            super(ImagesConst.LanternRiddlesBg);
            this.init();
            title = Language.getString(27725);
            return;
        }

        /* internal  */init(): void
        {
            var loc2=null;
            ObjCreate.createGTextField(Language.getString(27720), 14, 10, 100, 20, _bodySp, GlobalStyle.textFormat1);
            ObjCreate.createGTextField(Language.getString(27721), 14, 38, 100, 20, _bodySp, GlobalStyle.textFormat1);
            ObjCreate.createGTextField(Language.getString(27722), 14, 66, 100, 20, _bodySp, GlobalStyle.textFormat1);
            ObjCreate.createBg(-10, 29, 275, 2, _bodySp, ImagesConst.SeptalLine);
            ObjCreate.createBg(-10, 60, 275, 2, _bodySp, ImagesConst.SeptalLine);
            ObjCreate.createBg(-10, 170, 275, 2, _bodySp, ImagesConst.SeptalLine);
            this._rightNum = ObjCreate.createGTextField("", 75, 38, 100, 20, _bodySp, GlobalStyle.textFormatWhite);
            this._target = new TaskTargetInfo();
            this._target.mapId = MapIdRule.TaijiCity;
            this._target.x = 138;
            this._target.y = 157;
            this._target.targetType = EntityType.Point;
            var loc1=ObjCreate.createGButton(Language.getString(69858), 168, 35, 75, 24, _bodySp, "LinkButton");
            loc1.addEventListener(flash.events.MouseEvent.CLICK, this.onGoToBtnClick);
            loc2 = new FlyFootBmp();
            loc2.x = loc1.x + loc1.width - 8;
            loc2.y = loc1.y + 5;
            loc2.addEventListener(flash.events.MouseEvent.CLICK, this.onFlyToBtnClick);
            _bodySp.addChild(loc2);
            this._awardList = ObjCreate.createTileList(7, 85, 300, 82, _bodySp);
            this._awardList.scrollPolicy = ScrollPolicy.OFF;
            this._awardList.columnWidth = 63;
            this._awardList.rowHeight = 80;
            this._awardList.setStyle("cellRenderer", LRAwardItemRenderer);
            this._tfLeftTime = new SecTimerView();
            this._tfLeftTime.setParse(Language.getString(27726));
            this._tfLeftTime.defaultTextFormat = GlobalStyle.textFormatWhite;
            this._tfLeftTime.filters = [FilterConst.glowFilter];
            ObjCreate.setObjAttri(this._tfLeftTime, 75, 10, 200, 20, _bodySp);
            var loc3=ObjCreate.createFireTip(Language.getString(27724), 20, 172, _bodySp, true);
            return;
        }

        /* internal  */onGoToBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            AIManager.onAutoPathAIControl(this._target);
            return;
        }

        /* internal  */onFlyToBtnClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            AIManager.onAIControl(this._target, AIType.AI_Convey);
            return;
        }

        public set tfLeftTime(arg1: int)
        {
            this._tfLeftTime.setLeftTime(arg1);
            return;
        }

        public set rightNum(arg1: int)
        {
            if (this._rightNum) 
            {
                this._rightNum.text = String(arg1);
            }
            return;
        }

        public get rightNum(): int
        {
            if (this._rightNum) 
            {
                return int(this._rightNum.text);
            }
            return 0;
        }

        public set awardList(arg1: Map<any, any> /* flash.utils.Dictionary */)
        {
            var $value: Map<any, any> /* flash.utils.Dictionary */;
            var key: int;
            var keyArr: Array<any>;
            var arr: Array<any>;
            var vo: LRAwardItemVo;
            var keyCode: string;
            var i: int;
            var sortFun: Function;

            var loc1;
            key = 0;
            keyArr = null;
            arr = null;
            vo = null;
            keyCode = null;
            i = 0;
            $value = arg1;
            if ($value) 
            {
                sortFun = (arg1: int, arg2: int): int
                {
                    if (arg1 > arg2) 
                    {
                        return 1;
                    }
                    if (arg1 < arg2) 
                    {
                        return -1;
                    }
                    return 0;
                }
                keyArr = [];
                arr = [];
                var loc2=0;
                var loc3=$value;
                for (keyCode in loc3) 
                {
                    keyArr.push(int(keyCode));
                }
                keyArr.sort(sortFun);
                i = 0;
                while (i < keyArr.length) 
                {
                    key = keyArr[i];
                    vo = new LRAwardItemVo();
                    vo.itemCode = $value[key];
                    vo.needRightNum = key;
                    vo.rightNum = this.rightNum;
                    vo.index = i;
                    arr.push(vo);
                    ++i;
                }
                this._awardList.dataProvider = new DataProvider(arr);
                this._awardList.drawNow();
            }
            return;
        }

        /* internal */ /* var */_tfLeftTime: SecTimerView;

        /* internal */ /* var */_rightNum: GTextFiled;

        /* internal */ /* var */_awardList: GTileList;

        /* internal */ /* var */_target: TaskTargetInfo;
    }
